#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
bool is_leap_year(int year) {
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
		return true;
	else return false;
}
int get_days_of_month(int year, int month) {
	int days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int day = days[month];
	if (is_leap_year && month == 2)
		day += 1;
	return day;
}
int main() {
	int year, month;
	scanf("%d%d", &year, &month);
	printf("%d", get_days_of_month(year, month));
	return 0;
}
